package com.haidechizi.i18n.common.executor;

import com.haidechizi.i18n.common.api.I18nService;
import com.haidechizi.i18n.common.api.vo.SingleLanguage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;
import java.util.List;

@Slf4j
public class SimpleExecutor implements Executor {

    @Autowired
    private I18nService i18nService;

    @Override
    public List<SingleLanguage> queryLocaleInfo(String systemCode, String businessCode, String languageName,
                                                List<String> businessKeyList) {
        List<SingleLanguage> singleLanguageList = new ArrayList<>();
        try {
            singleLanguageList = i18nService.batchQuerySingleLanguage(systemCode,
                    businessCode, languageName, businessKeyList);

            /*singleLanguageList.forEach(el -> {
                String docJson = el.getDocJson();
                Map map = JSON.parseObject(docJson, Map.class);
                result.put(el.getBusinessKey(), map);
            });*/
        } catch (Exception e) {
            log.error("queryLocaleInfo failed systemCode:{},businessCode:{},languageName:{},businessKeyList:{} ",
                    systemCode, businessCode, languageName, businessKeyList, e);
        } finally {
            return singleLanguageList;
        }
    }
}
